<?php
/**
 * Created by 784855684@qq.com.
 * Link: https://github.com/lichtung/wshore
 * User: linzh
 * Date: 6/30/17
 * Time: 3:14 PM
 */
declare(strict_types=1);


namespace application\module\admin\addon;


use application\module\admin\addon\log\model\LogModel;

/**
 * Class Log 操作日志
 * @package application\module\admin\addon
 */
class Log extends Addon
{
    protected function getName(): string
    {
        return 'log';
    }

    public function models(): array
    {
        return [
            LogModel::class,
        ];
    }

    /**
     * 添加操作记录
     * @param string $action
     * @param string $content
     * @param int $uid
     * @return bool
     */
    public static function add(string $action, string $content, int $uid = 0): bool
    {
        $_model = new LogModel($uid);
        $_model->action = $action;
        $_model->content = $content;
        return $_model->save();
    }

}